<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="/static/images/favicon.png" type="image/png">
    <title> - 登录 - </title>
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/css/font-awesome.min.css" rel="stylesheet">
    <link href="/static/css/animate.min.css" rel="stylesheet">
    <link href="/static/css/style.min.css?v=3.3.0" rel="stylesheet">
    <link href="/static/css/login.min.css" rel="stylesheet">
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>
<body class="signin">
    <div class="signinpanel">
        <div class="row">
            <div class="col-sm-7">
                <div class="signin-info">
                   
                    <h4>欢迎使用 <strong>H+ 后台主题UI框架</strong></h4>
                  
                </div>
            </div>
            <div class="col-sm-5">
                <form onsubmit="return false" method="post">
                    <input type="text" name='user_name' class="form-control uname" placeholder="用户名" />
                    <input type="password" name='password' class="form-control pword m-b" placeholder="密码" />
                    <!-- <input name='code' style="width:45%;color: #333 !important;" type="text" class="form-control code" placeholder="验证码" />
                    <img id="captcha" onclick="fleshVerify()" src="{:url('/manage/verify')}" style="cursor: pointer;top: -31px;left: 113px;position: relative;" /> -->
                    <input type="text" style="width:70%;color: #333;" name='google_code' class="form-control" placeholder="请输入谷歌验证码" />
                    <button type="submit" onclick="login()" class="btn btn-success btn-block">登录</button>
                </form>
            </div>
        </div>
    </div>
</body>
<script src="/static/js/jquery.min.js?v=2.1.4"></script>
<script src="/static/js/plugins/layer/layer.min.js"></script>
<script>
//重载验证码
function fleshVerify(){
        $('#captcha').attr('src','/manage/verify?nonce_str='+Math.floor(Math.random()*100));
    }
    //去空格
    function trim(str){
        return str.replace(/(^\s*)|(\s*$)/g, "");
    }
    //登录
    function login(){
        var user_name = $("input[name='user_name']").val();
        var google_code = $("input[name='google_code']").val();
        var password = $("input[name='password']").val();
        //var code = $("input[name='code']").val();
        if(trim(user_name) == ""){
            parent.layer.msg("账号不能为空");
            return false;
        }
        if(trim(password) == ""){
            parent.layer.msg("密码不能为空");
            return false;
        }
        // if(trim(code) == ""){
        //     parent.layer.msg("验证码不能为空");
        //     return false;
        // }
        if(trim(google_code) == ""){
            parent.layer.msg("谷歌验证码不能为空");
            return false;
        }
        $.ajax({
            url: "{:url('/web/dologin')}",
            type:"POST",
            dataType:"json",
            data:{user_name:user_name,google_code:google_code,password:password},
            beforeSend:function(data){
                $(".btnSubmit").attr({ disabled: "disabled" });
                index = parent.layer.load(0, {shade: false});
            },
            success: function(data){
                parent.layer.msg(data.msg);
                if(data.code == 1){
                    setTimeout(function(){
                        window.location.href=data.url;
                    },1000);
                }
            },
            error: function(data){
                parent.layer.msg('网络失败，请刷新页面后重试!');
            },
            complete: function () {
                $(".btnSubmit").removeAttr("disabled");
                parent.layer.close(index);
                //fleshVerify();//刷新验证码
            }
        })
    }
</script>
</html>